﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Text.Json;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Entities;

namespace PasteLoggerBoard.serilogmodels
{
    /// <summary>
    /// 
    /// </summary>
    [CType("long")]
    [Index(nameof(DateLog), IsUnique = false)]
    public class LogError : Entity<long>
    {
        /// <summary>
        /// 应用名称 16
        /// </summary>
        [MaxLength(16)]
        public string AppName { get; set; } = "";

        /// <summary>
        /// 日志日期时间
        /// </summary>
        public DateTime DateLog { get; set; } = DateTime.Now;

        /// <summary>
        /// 日志等级 16
        /// </summary>
        [MaxLength(16)]
        public string Level { get; set; } = "";

        /// <summary>
        /// 消息模板 
        /// </summary>
        public string MessageTemplate { get; set; }

        /// <summary>
        /// 消息属性
        /// </summary>
        public JsonElement Properties { get; set; }

        /// <summary>
        /// 请求ID 32
        /// </summary>
        [MaxLength(32)]
        public string RequestId { get; set; }

        /// <summary>
        /// 请求路径 128
        /// </summary>
        [MaxLength(128)]
        public string Path { get; set; }

        /// <summary>
        /// 耗时 毫秒
        /// </summary>
        public double ElapsedMilliseconds { get; set; }

        /// <summary>
        /// 连接ID 32
        /// </summary>
        [MaxLength(32)]
        public string ConnectionId { get; set; }

        /// <summary>
        /// 状态码
        /// </summary>
        public int StatusCode { get; set; } = 200;

        /// <summary>
        /// 客户端IP 32
        /// </summary>
        [MaxLength(32)]
        public string ClientIp { get; set; }

        /// <summary>
        /// 异常信息
        /// </summary>
        public string Exception { get; set; }

        /// <summary>
        /// 访问域名 64
        /// </summary>
        [MaxLength(64)]
        public string Host { get; set; }


        /// <summary>
        /// 浏览器标识 128
        /// </summary>
        [MaxLength(128)]
        public string UserAgent { get; set; }
    }
}
